Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only compress responses if request was compressed #36867

Merged
merged 7 commits into from
Dec 21, 2018

Conversation

Tim-Brooks
Copy link
Contributor

This is a follow-up to some discussions around #36399. Currently we have
relatively confusing compression behavior where compression can be
configured for requests based on transport.compress or a specific
setting for a remote cluster. However, we can only compress responses
based on transport.compress as we do not know where a request is
coming from (currently).

This commit modifies the behavior to NEVER compress responses based on
settings. Instead, a response will only be compressed if the request was
compressed. This commit also updates the documentation to more clearly
described transport level compression.

This is a follow-up to some discussions around elastic#36399. Currently we have
relatively confusing compression behavior where compression can be
configured for requests based on `transport.compress` or a specific
setting for a remote cluster. However, we can only compress responses
based on `transport.compress` as we do not know where a request is
coming from (currently).

This commit modifies the behavior to NEVER compress responses based on
settings. Instead, a response will only be compressed if the request was
compressed. This commit also updates the documentation to more clearly
described transport level compression.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@Tim-Brooks
Copy link
Contributor Author

This PR is based on a conversation with I had with @jasontedor where I suggested it might be nicer to have simpler rules for compressing responses. Instead of having this odd edge-case where only some of the compression settings apply to responses, none of the compression settings will apply to responses 🤣.

I wanted to open this PR and see if others agreed. If we all agree and generally there is agreement that the description about compression I added to the documentation is correct, I'll add @lcawl as a specific reviewer to iron-out the language. But @lcawl - you can hold off reviewing until we agree that this is a change we want to make.

@ywelsch
Copy link
Contributor

ywelsch commented Dec 20, 2018

The change makes sense to me. Can you also add tests that check that we're getting the desired behavior with this change?

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

`cluster.remote.${cluster_alias}.transport.compress` setting.

When compression is enabled using either `transport.compress` or for a specific
remote cluster, only the outbound requests are compressed. Elasticsearch only
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elasticsearch only -> Elasticsearch

Copy link
Member

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM2

@Tim-Brooks
Copy link
Contributor Author

@lcawl - I think that we're at a point where it is probably worth you reviewing the documentation.

noticeable CPU cost and local clusters tend to be setup with fast network
connections between nodes. If compression is necessary for remote cluster
connections only, this can be configured on a per-cluster basis using the
`cluster.remote.${cluster_alias}.transport.compress` setting.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`cluster.remote.${cluster_alias}.transport.compress` setting.
<<remote-cluster-settings,`cluster.remote.${cluster_alias}.transport.compress` setting>>.

[float]
==== Transport Compression

By default Elasticsearch network-level compression is disabled. This default
Copy link
Contributor

@lcawl lcawl Dec 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default Elasticsearch network-level compression is disabled. This default
By default, the `transport.compress` setting is `false` and network-level compression is disabled between nodes in the cluster. This default


By default Elasticsearch network-level compression is disabled. This default
normally makes sense for local cluster communication as compression has a
noticeable CPU cost and local clusters tend to be setup with fast network
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
noticeable CPU cost and local clusters tend to be setup with fast network
noticeable CPU cost and local clusters tend to be set up with fast network

By default Elasticsearch network-level compression is disabled. This default
normally makes sense for local cluster communication as compression has a
noticeable CPU cost and local clusters tend to be setup with fast network
connections between nodes. If compression is necessary for remote cluster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
connections between nodes. If compression is necessary for remote cluster
connections between nodes. If you want to compress remote cluster

normally makes sense for local cluster communication as compression has a
noticeable CPU cost and local clusters tend to be setup with fast network
connections between nodes. If compression is necessary for remote cluster
connections only, this can be configured on a per-cluster basis using the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "only" here seems to imply that setting transport.compress affects both internode and remote cluster communications. i.e. you set this cluster-level setting if you only want to compress remote cluster connections. If that's not right, we should remove the "only".

`cluster.remote.${cluster_alias}.transport.compress` setting.

When compression is enabled using either `transport.compress` or for a specific
remote cluster, only the outbound requests are compressed. Elasticsearch compresses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
remote cluster, only the outbound requests are compressed. Elasticsearch compresses
remote cluster, only the outbound requests are compressed.


When compression is enabled using either `transport.compress` or for a specific
remote cluster, only the outbound requests are compressed. Elasticsearch compresses
responses if and only-if the inbound request received was compressed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
responses if and only-if the inbound request received was compressed.
If compression is enabled and an inbound request is compressed, {es} also compresses the response.

Copy link
Contributor

@lcawl lcawl Dec 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's true that the compression of responses requires compression to be enabled, but it seemed like a reasonable assumption. If that's not true, I'd suggest something like this:

Suggested change
responses if and only-if the inbound request received was compressed.
If an inbound request is compressed, {es} compresses the response--even when compression is not enabled.

@Tim-Brooks
Copy link
Contributor Author

@lcawl - I made some changes. I went ahead and split it into request and response sections to be completely clear.

Copy link
Contributor

@lcawl lcawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tim-Brooks
Copy link
Contributor Author

Thanks @lcawl

@Tim-Brooks Tim-Brooks merged commit c8a8391 into elastic:master Dec 21, 2018
Tim-Brooks added a commit to Tim-Brooks/elasticsearch that referenced this pull request Dec 21, 2018
This is a follow-up to some discussions around elastic#36399. Currently we have
relatively confusing compression behavior where compression can be
configured for requests based on transport.compress or a specific
setting for a remote cluster. However, we can only compress responses
based on transport.compress as we do not know where a request is
coming from (currently).

This commit modifies the behavior to NEVER compress responses based on
settings. Instead, a response will only be compressed if the request was
compressed. This commit also updates the documentation to more clearly
described transport level compression.
jasontedor added a commit to ywelsch/elasticsearch that referenced this pull request Dec 21, 2018
* elastic/master: (539 commits)
  SQL: documentation improvements and updates (elastic#36918)
  [DOCS] Merges list of discovery and cluster formation settings (elastic#36909)
  Only compress responses if request was compressed (elastic#36867)
  Remove duplicate paragraph (elastic#36942)
  Fix URI to cluster stats endpoint on specific nodes (elastic#36784)
  Fix typo in unitTest task (elastic#36930)
  RecoveryMonitor#lastSeenAccessTime should be volatile (elastic#36781)
  [CCR] Add `ccr.auto_follow_coordinator.wait_for_timeout` setting (elastic#36714)
  Scripting: Remove deprecated params.ctx (elastic#36848)
  Refactor the REST actions to clarify what endpoints are deprecated. (elastic#36869)
  Add JDK 12 to CI rotation (elastic#36915)
  Improve error message for 6.x style realm settings (elastic#36876)
  Send clear session as routable remote request (elastic#36805)
  [DOCS] Remove redundant ILM attributes (elastic#36808)
  SQL: Fix bug regarding histograms usage in scripting (elastic#36866)
  Update index mappings when ccr restore complete (elastic#36879)
  Docs: Bump version to alpha2 after release
  Enable IPv6 URIs in reindex from remote (elastic#36874)
  Watcher: Remove unused local variable in doExecute (elastic#36655)
  [DOCS] Synchs titles of X-Pack APIs
  ...
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Dec 21, 2018
* master: (31 commits)
  Move ingest-geoip default databases out of config (elastic#36949)
  [ILM][DOCS] add extra scenario to policy update docs (elastic#36871)
  [Painless] Add String Casting Tests (elastic#36945)
  SQL: documentation improvements and updates (elastic#36918)
  [DOCS] Merges list of discovery and cluster formation settings (elastic#36909)
  Only compress responses if request was compressed (elastic#36867)
  Remove duplicate paragraph (elastic#36942)
  Fix URI to cluster stats endpoint on specific nodes (elastic#36784)
  Fix typo in unitTest task (elastic#36930)
  RecoveryMonitor#lastSeenAccessTime should be volatile (elastic#36781)
  [CCR] Add `ccr.auto_follow_coordinator.wait_for_timeout` setting (elastic#36714)
  Scripting: Remove deprecated params.ctx (elastic#36848)
  Refactor the REST actions to clarify what endpoints are deprecated. (elastic#36869)
  Add JDK 12 to CI rotation (elastic#36915)
  Improve error message for 6.x style realm settings (elastic#36876)
  Send clear session as routable remote request (elastic#36805)
  [DOCS] Remove redundant ILM attributes (elastic#36808)
  SQL: Fix bug regarding histograms usage in scripting (elastic#36866)
  Update index mappings when ccr restore complete (elastic#36879)
  Docs: Bump version to alpha2 after release
  ...
Tim-Brooks added a commit that referenced this pull request Dec 22, 2018
This is a follow-up to some discussions around #36399. Currently we have
relatively confusing compression behavior where compression can be
configured for requests based on transport.compress or a specific
setting for a remote cluster. However, we can only compress responses
based on transport.compress as we do not know where a request is
coming from (currently).

This commit modifies the behavior to NEVER compress responses based on
settings. Instead, a response will only be compressed if the request was
compressed. This commit also updates the documentation to more clearly
described transport level compression.
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
@Tim-Brooks Tim-Brooks deleted the only_compress_requests branch December 18, 2019 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Network Http and internode communication implementations >non-issue v6.7.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants